<template>
	<view class="login">
		<!-- 顶部背景 -->
		<view class="login-logo">
			<image src="../../static/logo1.png" mode=""></image>
		</view>
		<view class="title">
			火箭收货
		</view>
		<view class="content-box">
			<view class="box-item">
				
				<u-input v-model="account" type="Number" :border="true" border-color="#F5F5F6 " placeholder="请输入账号" />
			</view>
			<view class="box-item">
				<u-input v-model="password" type="password" :border="true" border-color="#F5F5F6 " placeholder="请输入密码" />
			</view>
			<view class="checkd">
				
				<u-checkbox-group >
				<u-checkbox v-model="item.checked" 
								v-for="(item, index) in list" :key="index" 
								:name="item.name"
							>记住登陆信息</u-checkbox>
						</u-checkbox-group>

			</view>
			<view class="box-item">
				<view class="btn" @click="login">
					登 录
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		login
	} from '@/api/all.js';
	export default {
		data() {
			return {
				list: [
						{
						name: 'apple',
						checked: false,
						disabled: false
						}
						],
				account: '',
				password: '',
				value:'0',
				loading: false,
			}
		},
		mounted() {
			// this.getData();
		},
		methods: {
		
			// 选中某个复选框时，由checkbox时触发
					checkboxChange(e) {
						//console.log(e);
					},
					// 选中任一checkbox时，由checkbox-group触发
					checkboxGroupChange(e) {
						// console.log(e);
					},
			// 登录
			login() {
				let _this = this
				if (this.account == "") {
					uni.showToast({
						title: '账号不能为空',
						icon: 'none',
						duration: 2000
					})
					return;
				}
				if (this.password == "") {
					uni.showToast({
						title: '密码不能为空',
						icon: 'none',
						duration: 2000
					})
					return;
				}
				let postdata = {
					userName: this.account,
					pwd: this.password
				};
				this.loading = true;
				login(postdata).then(res => {
					this.loading = false;
					console.log('res.data.Data.Token',  res.data.Data.Token)
					uni.setStorageSync('token',res.data.Data.Token);
					uni.setStorageSync('userinfo',res.data.Data);
					// uni.setStorageSync('islogin','1');
					setTimeout(() => {
					uni.navigateTo({
					url: '/pages/index/index'
					})
					}, 200)
				})
			}
		}
	}
</script>

<style lang="scss">
	.login {
		display: block;
		position: relative;
		width: 100%;
		height: 100vh;
		background: #ffffff;
		overflow: auto;

		.login-logo {
			display: flex;
			justify-content: center;
			margin-top: 25%;
			image{
				width: 340rpx;
				height: 340rpx;
			}
		}

		.title {
			font-size: 68rpx;
			color: #3D3D3D;
			font-weight: 500;
			display: flex;
			align-items: center;
			justify-content: center;

		}

		.content-box {
			margin-top: 20%;
			margin-left: 32rpx;
			margin-right: 32rpx;

			.box-item {
				margin-bottom: 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: #666666;
				background: #F5F5F6;
				border-radius: 15rpx;
				height: 88rpx;
 
				.btn {
					background: #376DFF;
					color: #FFFFFF;
					width: 100%;
					height: 100rpx;
					border-radius: 50rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}

			.box-item1 {
				margin-bottom: 60rpx;
				font-size: 24rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: #666666;

			}


			.checkd {
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 40rpx 0;
			}
		}
	}
</style>
